#include "mainwindow.h"
#include "plane.h"
#include "gamelevel.h"
#include <QApplication>
#include <QResource>

int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QCoreApplication::setOrganizationName("xy.chen");
    QCoreApplication::setOrganizationDomain("cyril.tech");
    QCoreApplication::setApplicationName("ThunderRaid");

    // 加载游戏资源
    const QString resource_path = QApplication::applicationDirPath().append("/resources.rcc");
    qDebug()<<QString("Loading Resource: %1").arg(resource_path);
    if(!QResource::registerResource(resource_path)){
        qDebug()<<QString("Failed to Load Resource: %1").arg(resource_path);
        return -1;
    }
    qDebug()<<"Loading Resource Success!";
    BulletFactor::addHeroBullet("normal", {"normal", QPixmap("://bullet/hero_bullet_1.png"), 30, -0.5, 300});
    BulletFactor::addHeroBullet("heavy", {"heavy",QPixmap("://bullet/hero_bullet_2.png"), 40, -0.5, 550});
    BulletFactor::addHeroBullet("fast", {"fast",QPixmap("://bullet/hero_bullet_3.png"), 30, -1, 150});
    BulletFactor::addHeroBullet("missile", {"missile", QPixmap("://bullet/hero_bullet_4.png"), 120, -0.75, 800});


    BulletFactor::addEnemyBullet("normal", {"normal", QPixmap("://bullet/bullet_1.png"), 30, 0.5, 500});
    BulletFactor::addEnemyBullet("heavy", {"heavy",QPixmap("://bullet/bullet_2.png"), 40, 0.5, 750});
    BulletFactor::addEnemyBullet("fast", {"fast", QPixmap("://bullet/bullet_3.png"), 30, 1, 300});

    PlaneFactor::addHeroPlane("hero1", {QPixmap("://plane/hero.png"), 100, 0.25, "fast"});
    PlaneFactor::addHeroPlane("hero2", {QPixmap("://plane/hero2.png"), 100, 0.25, "normal"});

    PlaneFactor::addEnemyPlane("normal",{QPixmap("://plane/img-plane_1.png"), 100, 0.2, "normal"});
    PlaneFactor::addEnemyPlane("heavy",{QPixmap("://plane/img-plane_2.png"), 300, 0.2, "heavy"});
    PlaneFactor::addEnemyPlane("fast",{QPixmap("://plane/img-plane_3.png"), 20, 0.25, "fast"});

    PlaneFactor::addEnemyPlane("boos1", {QPixmap("://plane/img-plane_boos_1.png"), 500, 0.2, "heavy"});
    PlaneFactor::addEnemyPlane("boos2", {QPixmap("://plane/img-plane_boos_2.png"), 800, 0.2, "heavy"});

    GameLevel::levelList.insert("official1"
        ,{"official1", "第一关", QPixmap("://background/img_bg_level_1.jpg"), {"normal", "normal", "normal", "normal", "normal"}, {}, "official2"});
    GameLevel::levelList.insert("official2"
        ,{"official2", "第二关", QPixmap("://background/img_bg_level_2.jpg"), {"normal", "normal", "heavy", "fast", "normal"}, {}, "official3"});
    GameLevel::levelList.insert("official3"
        ,{"official3", "第三关", QPixmap("://background/img_bg_level_3.jpg"), {"normal", "normal", "heavy", "fast", "normal"}, {"boos1"}, "official4"});
    GameLevel::levelList.insert("official4"
        ,{"official4", "第四关", QPixmap("://background/img_bg_level_4.jpg"), {"normal", "heavy", "fast", "fast", "normal"}, {}, "official5"});
    GameLevel::levelList.insert("official5"
        ,{"official5", "第五关", QPixmap("://background/img_bg_level_5.jpg"), {"heavy", "heavy", "fast", "fast", "normal"}, {"boos2"}, ""});

    MainWindow w;
    w.show();

    return app.exec(); // NOLINT(readability-static-accessed-through-instance)
}
